unit MainFm;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  ComCtrls, ActnList, Menus, ExtCtrls;

type

  { TMainForm }

  TMainForm = class(TForm)
    GContPagAction: TAction;
    GLancamentoAction: TAction;
    GContRecAction: TAction;
    GRecDespesaAction: TAction;
    GerencialAction: TAction;
    TransferenciaCadastroAction: TAction;
    MovimentacaoContaCadastroAction: TAction;
    PlanoContaCadastroAction: TAction;
    CentroCustoCadastroAction: TAction;
    DuplPagSearchAction: TAction;
    ControleMesaAction: TAction;
    SaidaCadastroAction: TAction;
    ContaCadastroAction: TAction;
    ConfiguracaoCadastroAction: TAction;
    GarconCadastroAction: TAction;
    MesaCadastroAction: TAction;
    EstoqueMinAction: TAction;
    EstoqueProdAction: TAction;
    EstoqueConsAction: TAction;
    PontosVendasMDAAction: TAction;
    CFOPCadAction: TAction;
    AlteraSenhaAction: TAction;
    CFOPSearchAction: TAction;
    CidadeCadastroAction: TAction;
    CidadeSearcAction: TAction;
    ClienteSearchAction: TAction;
    EncerraSessaoAction: TAction;
    GrupoCadastroAction: TAction;
    GrupoSearchAction: TAction;
    MarcaCadastroAction: TAction;
    MarcaSearchAction: TAction;
    PessoaCadastroAction: TAction;
    PessoaSearchAction: TAction;
    GeralActionList: TActionList;
    ProdutoCadastroAction: TAction;
    EntradaCadastroAction: TAction;
    BaixaDuplicataRecCadastroAction: TAction;
    DuplPagCadastroAction: TAction;
    DuplPagBaixaAction: TAction;
    DuplRecSearchAction: TAction;
    CaixaInicioCadastroAction: TAction;
    CaixaFecharCadastroAction: TAction;
    HistoricoCadastroAction: TAction;
    RamoCadastroAction: TAction;
    RamoSearchAction: TAction;
    SairAction: TAction;
    UnidadeCadastroAction: TAction;
    UnidadeSearchAction: TAction;
    VendaCadastroAction: TAction;
    GeralMDAction: TAction;
    CargoCadastroAction: TAction;
    UsuarioCadastroAction: TAction;
    PerfilFuncCadastroAction: TAction;
    CfopCadastroAction: TAction;
    CondicaoPagamentoCadastroAction: TAction;
    ClienteCadastroAction: TAction;
    EmpresaCadastroAction: TAction;
    FuncionarioCadastroAction: TAction;
    FornecedorCadAction: TAction;
    PessoaCadAction: TAction;
    PerfilCadastroAction: TAction;
    AdmMDAction: TAction;
    CaixaMDAction: TAction;
    DuplicatasMDAction: TAction;
    EstoqueMDAction: TAction;
    ModulosActionList: TActionList;
    PontoVendaMDAction: TAction;
    PrincipalImageList: TImageList;
    ModulosImageList: TImageList;
    MenuItem14: TMenuItem;
    MenuItem15: TMenuItem;
    MenuItem16: TMenuItem;
    MenuItem17: TMenuItem;
    MenuItem18: TMenuItem;
    MenuItem2: TMenuItem;
    FornecedorCadastroAction: TAction;
    MenuItem1: TMenuItem;
    MenuItem10: TMenuItem;
    MenuItem11: TMenuItem;
    MenuItem12: TMenuItem;
    MenuItem13: TMenuItem;
    MenuItem3: TMenuItem;
    MenuItem4: TMenuItem;
    MenuItem5: TMenuItem;
    MenuItem6: TMenuItem;
    MenuItem7: TMenuItem;
    MenuItem9: TMenuItem;
    PopupMenuArquivo: TPopupMenu;
    PopupMenuCadastro: TPopupMenu;
    PopupMenuPesquisa: TPopupMenu;
    PrincipalActionList: TActionList;
    ToolBar1: TToolBar;
    ToolBar2: TToolBar;
    ToolButton1: TToolButton;
    ToolButton11: TToolButton;
    ToolButton12: TToolButton;
    ToolButtonSair: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    ToolButton9: TToolButton;
    VendaFeitaAction: TAction;
    VendasMDAction: TAction;
    procedure Action1Execute(Sender: TObject);
    procedure AdmMDActionExecute(Sender: TObject);
    procedure AlteraSenhaActionExecute(Sender: TObject);
    procedure BaixaDuplicataPagCadastroActionExecute(Sender: TObject);
    procedure BaixaDuplicataRecCadastroActionExecute(Sender: TObject);
    procedure CaixaActionExecute(Sender: TObject);
    procedure CaixaFinalCadastroActionExecute(Sender: TObject);
    procedure CaixaInicioCadastroActionExecute(Sender: TObject);
    procedure CaixaMDActionExecute(Sender: TObject);
    procedure CargoCadastroActionExecute(Sender: TObject);
    procedure CentroCustoCadastroActionExecute(Sender: TObject);
    procedure CfopCadastroActionExecute(Sender: TObject);
    procedure CFOPSearchActionExecute(Sender: TObject);
    procedure CidadeCadastroActionExecute(Sender: TObject);
    procedure CidadeSearcActionExecute(Sender: TObject);
    procedure ClienteCadastroActionExecute(Sender: TObject);
    procedure ClienteSearchActionExecute(Sender: TObject);
    procedure CondicaoPagamentoCadastroActionExecute(Sender: TObject);
    procedure ConfiguracaoCadastroActionExecute(Sender: TObject);
    procedure ContaCadastroActionExecute(Sender: TObject);
    procedure DuplicatasMDActionExecute(Sender: TObject);
    procedure ControleMesaActionExecute(Sender: TObject);
    procedure DuplicataPagarCadastroActionExecute(Sender: TObject);
    procedure DuplRecSearchActionExecute(Sender: TObject);
    procedure EmpresaCadastroActionExecute(Sender: TObject);
    procedure EncerraSessaoActionExecute(Sender: TObject);
    procedure EntradaCadastroActionExecute(Sender: TObject);
    procedure EstoqueConsActionExecute(Sender: TObject);
    procedure EstoqueMDActionExecute(Sender: TObject);
    procedure EstoqueMinActionExecute(Sender: TObject);
    procedure EstoqueProdActionExecute(Sender: TObject);
    procedure FuncionarioCadastroActionExecute(Sender: TObject);
    procedure GarconCadastroActionExecute(Sender: TObject);
    procedure GContPagActionExecute(Sender: TObject);
    procedure GContRecActionExecute(Sender: TObject);
    procedure GeralMDActionExecute(Sender: TObject);
    procedure GerencialActionExecute(Sender: TObject);
    procedure GLancamentoActionExecute(Sender: TObject);
    procedure GRecDespesaActionExecute(Sender: TObject);
    procedure GrupoCadastroActionExecute(Sender: TObject);
    procedure GrupoSearchActionExecute(Sender: TObject);
    procedure MarcaCadastroActionExecute(Sender: TObject);
    procedure MarcaSearchActionExecute(Sender: TObject);
    procedure MesaCadastroActionExecute(Sender: TObject);
    procedure MovimentacaoContaCadastroActionExecute(Sender: TObject);
    procedure PerfilCadastroActionExecute(Sender: TObject);
    procedure PerfilFuncCadastroActionExecute(Sender: TObject);
    procedure PessoaCadastroActionExecute(Sender: TObject);
    procedure PessoaSearchActionExecute(Sender: TObject);
    procedure PlanoContaCadastroActionExecute(Sender: TObject);
    procedure ProdutoCadastroActionExecute(Sender: TObject);
    procedure RamoCadastroActionExecute(Sender: TObject);
    procedure RamoSearchActionExecute(Sender: TObject);
    procedure SaidaCadastroActionExecute(Sender: TObject);
    procedure SairActionExecute(Sender: TObject);
    procedure TransferenciaCadastroActionExecute(Sender: TObject);
    procedure UnidadeCadastroActionExecute(Sender: TObject);
    procedure FornecedorCadastroActionExecute(Sender: TObject);
    procedure UnidadeSearchActionExecute(Sender: TObject);
    procedure UsuarioCadastroActionExecute(Sender: TObject);
    procedure VendaCadastroActionExecute(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure VendaFeitaActionExecute(Sender: TObject);
    procedure VendasMDActionExecute(Sender: TObject);
    procedure IniciaUsuario(IDUsuario: integer);
  private
    { private declarations }
  public
    { public declarations }
    Usuario: integer;
    Maquina: string;
  end;

var
  MainForm: TMainForm;

implementation

uses Initializator, UsuarioDM, mainfr, UsuarioTrocaFm, UsuarioLoginFm, CaixaDM;

{ TMainForm }

procedure TMainForm.FormCreate(Sender: TObject);
begin
  // Inicializa os frames
  InitializeFrames();
  //Controla Botões e Acesso dos Usuários
end;

procedure TMainForm.IniciaUsuario(IDUsuario: integer);
begin
  UsuarioData.HabilitaAcoes(IDUsuario);
  Usuario := IDUsuario;
  Maquina := 'PRINCIPAL';
end;

procedure TMainForm.VendaFeitaActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(VendaRecordFrame));
end;

procedure TMainForm.VendasMDActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(VendasFrame));
end;

procedure TMainForm.FuncionarioCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(FuncionarioRecordFrame));
end;

procedure TMainForm.GarconCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(GarconRecordFrame));
end;

procedure TMainForm.GContPagActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(ContasPagarFrame));
end;

procedure TMainForm.GContRecActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(ContasReceberFrame));
end;

procedure TMainForm.GeralMDActionExecute(Sender: TObject);
begin
  //Geral Modulo - Ações do Menu
end;

procedure TMainForm.GerencialActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(GerencialMainFrame));
end;

procedure TMainForm.GLancamentoActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(LancamentosFrame));
end;

procedure TMainForm.GRecDespesaActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(ReceitaDespesaAnualFrame));
end;

procedure TMainForm.GrupoCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(GrupoRecordFrame));
end;

procedure TMainForm.GrupoSearchActionExecute(Sender: TObject);
begin
  TheControl.ShowSearchFrame(TMainFrame(GrupoSearchFrame));
end;

procedure TMainForm.MarcaCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(MarcaRecordFrame));
end;

procedure TMainForm.MarcaSearchActionExecute(Sender: TObject);
begin
  TheControl.ShowSearchFrame(TMainFrame(MarcaSearchFrame));
end;

procedure TMainForm.MesaCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(MesaRecordFrame));
end;

procedure TMainForm.MovimentacaoContaCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(ContaMovimentacaoRecordFrame));
end;

procedure TMainForm.PerfilCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(PerfilRecordFrame));
end;

procedure TMainForm.PerfilFuncCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(PerfilFunc2RecordFrame));
end;

procedure TMainForm.PessoaCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(PessoaRecorFrame));
end;

procedure TMainForm.PessoaSearchActionExecute(Sender: TObject);
begin
  TheControl.ShowSearchFrame(TMainFrame(PessoaSearchFrame));
end;

procedure TMainForm.PlanoContaCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(PlanoContaRecordFrame));
end;

procedure TMainForm.ProdutoCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(ProdutoRecordFrame));
end;

procedure TMainForm.RamoCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(RamoRecordFrame));
end;

procedure TMainForm.RamoSearchActionExecute(Sender: TObject);
begin
  TheControl.ShowSearchFrame(TMainFrame(RamoSearchFrame));
end;

procedure TMainForm.SaidaCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(SaidaRecordFrame));
end;

procedure TMainForm.SairActionExecute(Sender: TObject);
begin
  Application.Terminate;
end;

procedure TMainForm.TransferenciaCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(TransferenciaRecordFrame));
end;

procedure TMainForm.UnidadeCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(UnidadeRecordFrame));
end;

procedure TMainForm.FornecedorCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(FornecedorRecordFrame));
end;

procedure TMainForm.UnidadeSearchActionExecute(Sender: TObject);
begin
  TheControl.ShowSearchFrame(TMainFrame(UnidadeSearchFrame));
end;

procedure TMainForm.UsuarioCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(UsuarioRecordFrame));
end;

procedure TMainForm.VendaCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(ControleMesaFrame));
  ControleMesaFrame.Inicia();
end;

procedure TMainForm.CidadeCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(CidadeRecordFrame));
end;

procedure TMainForm.CidadeSearcActionExecute(Sender: TObject);
begin
  TheControl.ShowSearchFrame(TMainFrame(CidadeSearchFrame));
end;

procedure TMainForm.ClienteCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(ClienteRecordFrame));
end;

procedure TMainForm.ClienteSearchActionExecute(Sender: TObject);
begin
  TheControl.ShowSearchFrame(TMainFrame(ClienteSearchFrame));
end;

procedure TMainForm.CondicaoPagamentoCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(CondicaoPagTransRecordFrame));
end;

procedure TMainForm.ConfiguracaoCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(ConfiguracaoRecordFrame));
end;

procedure TMainForm.ContaCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(ContaRecordFrame));
end;

procedure TMainForm.DuplicatasMDActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(DuplicatasFrame));
end;

procedure TMainForm.ControleMesaActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(ControleMesaFrame));
  ControleMesaFrame.Inicia();
end;

procedure TMainForm.DuplicataPagarCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(DuplicataPagarRecordFrame));
end;

procedure TMainForm.DuplRecSearchActionExecute(Sender: TObject);
begin
  TheControl.ShowSearchFrame(TMainFrame(DuplicataRecSearchFrame));
end;

procedure TMainForm.EmpresaCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(EmpresaRecordFrame));
end;

procedure TMainForm.EncerraSessaoActionExecute(Sender: TObject);
begin
  Hide();
  UsuarioLoginForm.Show();
end;

procedure TMainForm.EntradaCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(EntradaTransRecordFrame));
end;

procedure TMainForm.EstoqueConsActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(EstoqueConsumoFrame));
end;

procedure TMainForm.EstoqueMDActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(EstoqueProdutoFrame));
end;

procedure TMainForm.EstoqueMinActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(EstoqueMininoFrame));
end;

procedure TMainForm.EstoqueProdActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(EstoqueProdutoFrame));
end;


procedure TMainForm.CargoCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(CargoRecordFrame));
end;

procedure TMainForm.CentroCustoCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(CentroCustoRecordFrame));
end;

procedure TMainForm.CaixaInicioCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(CaixaInicioRecordFrame));
end;

procedure TMainForm.CaixaMDActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(CaixaFrame));
  CaixaMovimentacaoData.BuscaDadosCaixaMainFrame();
  if MainForm.ContaCadastroAction.Enabled = True then begin
    CaixaFrame.DBGrid2.Visible := True;
  end;
end;

procedure TMainForm.CaixaFinalCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(CaixaFimRecordFrame));
end;

procedure TMainForm.BaixaDuplicataPagCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(PagDuplicataPagRecordFrame));
end;

procedure TMainForm.AdmMDActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(AdministrativoFrame));
end;

procedure TMainForm.Action1Execute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(VendaAbertaTransRecordFrame));
end;


procedure TMainForm.AlteraSenhaActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(TrocaSenhaRecordFrame));
end;

procedure TMainForm.BaixaDuplicataRecCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(PagDuplicataRecRecordFrame));
end;

procedure TMainForm.CaixaActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(CaixaVendasRecordFrame));
end;

procedure TMainForm.CfopCadastroActionExecute(Sender: TObject);
begin
  TheControl.ShowFrame(TMainFrame(CfopRecordFrame));
end;

procedure TMainForm.CFOPSearchActionExecute(Sender: TObject);
begin
  TheControl.ShowSearchFrame(TMainFrame(CfopSearchFrame));
end;

initialization
  {$I mainfm.lrs}

end.

